import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui';import 'element-ui/lib/theme-chalk/index.css';import axios from 'axios'

import * as echarts from 'echarts';
Vue.prototype.$echarts = echarts;


import { Message } from 'element-ui';
//
Vue.config.productionTip = false





Vue.use(ElementUI) 
axios.defaults.baseURL = "http://www.pawntest.com"
axios.defaults.withCredentials = true

//axios守卫
axios.interceptors.response.use(function(resp) {
	// console.log(resp)
	if(resp.data.statusCode == 9999) {
		localStorage.removeItem("com.woniu-account");
		Message.error(resp.data.message);
		router.push("/");
	} else {
		if(resp.data.statusCode == 200) {
			if(resp.data.message!=null){
				
				Message.success(resp.data.message)
			}
		}
		if(resp.data.flag == false){
			Message.error(resp.data.message)
		}
		return resp;
	}
})
router.beforeEach((to,from,next) => {
	if(to.path == '/') {
		next();
	}else if (to.path == '/user'){
		next();
	}else {
		let json = localStorage.getItem("com.woniu-account");
		if(json == null || json == undefined || json == "") {
			router.push("/");
		} else {
			next();
		}
	}
	
})








Vue.prototype.$http = axios

Vue.config.productionTip = false


new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
